package com.xxx.meter.ui.info.adapter;

import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xxx.meter.R;
import com.xxx.meter.model.http.bean.MachineChildBean;

import java.util.List;

public class IndexDeviceAdapter extends BaseQuickAdapter<MachineChildBean, BaseViewHolder> {

    private int position = -1;

    public void setPosition(int position) {
        this.position = position;
        notifyDataSetChanged();
    }

    public int getPosition() {
        return position;
    }

    public IndexDeviceAdapter(@Nullable List<MachineChildBean> data) {
        super(R.layout.item_machine, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MachineChildBean item) {
        helper.setText(R.id.item_machine_text, item.getName());
        ImageView imageView = helper.getView(R.id.item_machine_image);

        if (helper.getAdapterPosition() == position) {
            imageView.setImageResource(R.mipmap.tag1);
        } else {
            imageView.setImageResource(R.mipmap.tag2);
        }
    }
}
